export default function useGod(babel) {
  const { types: t, template } = babel
  const useGod = template(`
const useGod = () => '我不掷骰子'
`)
  return {
    name: 'ast-transform', // not required
    visitor: {
      CallExpression(path) {
        if (
          path.node.callee.type === 'Identifier' &&
          path.node.callee.name === 'useGod'
        ) {
          let programPath = path.parentPath
          while (programPath.type !== 'Program') {
            programPath = programPath.parentPath
          }
          programPath.node.body.unshift(useGod())
        }
      },
    },
  }
}
